import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

class Process {
    int id;
    int arrivalTime;
    int burstTime;
    int priority;
    int remainingTime;
    String status;

    public int getArrivalTime() {
        return arrivalTime;
    }

    public Process(int id, int arrivalTime, int burstTime, int priority) {
        this.id = id;
        this.arrivalTime = arrivalTime;
        this.burstTime = burstTime;
        this.priority = priority;
        this.remainingTime = burstTime;
        this.status = "Waiting";
    }

    public void run() {
        this.status = "Running";
    }

    public void await() {
        this.status = "Waiting";
    }

    public void complete() {
        this.status = "Completed";
    }

    public void decreasePriority() {
        this.priority -= 2;
        if (this.priority < 0) {
            this.priority = 0;
        }
    }

    @Override
    public String toString() {
        return "Process{" +
                "id=" + id +
                ", arrivalTime=" + arrivalTime +
                ", burstTime=" + burstTime +
                ", priority=" + priority +
                ", remainingTime=" + remainingTime +
                ", status='" + status + '\'' +
                '}';
    }
}

public class ProcessorScheduler {
    public static void main(String[] args) {
        List<Process> processes = new ArrayList<>();
        processes.add(new Process(1, 0, 4, 5));
        processes.add(new Process(2, 1, 3, 7));
        processes.add(new Process(3, 2, 1, 3));
        processes.add(new Process(4, 3, 2, 6));

        int currentTime = 0;
        boolean allCompleted = false;

        while (!allCompleted) {
            processes.sort(Comparator.comparingInt(Process::getArrivalTime).thenComparingInt(p -> -p.priority));

            List<Process> runnableProcesses = new ArrayList<>();
            for (Process p : processes) {
                if (p.arrivalTime <= currentTime && p.status != "Completed") {
                    runnableProcesses.add(p);
                }
            }

            if (runnableProcesses.isEmpty()) {
                currentTime++;
                continue;
            }

            Process currentProcess = runnableProcesses.get(0);
            currentProcess.run();

            currentProcess.remainingTime--;
            currentTime++;

            System.out.println("Time " + currentTime + ":");
            for (Process p : processes) {
                System.out.println(p);
            }

            if (currentProcess.remainingTime <= 0) {
                currentProcess.complete();
            } else {
                currentProcess.decreasePriority();
            }

            allCompleted = true;
            for (Process p : processes) {
                if (p.status != "Completed") {
                    allCompleted = false;
                    break;
                }
            }
        }
    }
}